package com.ksyun.client;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.ksyun.client.domain.dto.ServiceInstance;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;

import java.util.UUID;

import static com.ksyun.client.service.impl.ClientServiceImpl.register;
import static com.ksyun.client.service.impl.ClientServiceImpl.unregister;

@SpringBootApplication
@EnableScheduling // 启用定时任务
public class ClientApplication {

    public static void main(String[] args) {
        SpringApplication.run(ClientApplication.class,args);
        //启动的时候将信息注册到服务中心
        try {
            register();
        }catch (Exception e){
        }
        // 添加关闭钩子
        Runtime.getRuntime().addShutdownHook(new Thread(() -> {
            // 程序结束，发送结束的消息
            try{
                unregister();
            }catch (Exception e){

            }
        }));
    }
}
